package com.example.demo.model.meta;

import com.baidu.bas.annotation.Erupt;
import com.baidu.bas.annotation.EruptField;
import com.baidu.bas.annotation.sub_field.Edit;
import com.baidu.bas.annotation.sub_field.EditType;
import com.baidu.bas.annotation.sub_field.View;
import com.baidu.bas.upms.model.base.HyperModel;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.TypeDef;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.io.Serializable;

/**
 * ID 类型
 * @author liuzhenchuan@foxmail.com
 * @date 2020/12/22
 */
@Setter
@Getter
@Erupt(name = "ID类型",orderBy = "id desc")
@Table(name = "ma_meta_identity",uniqueConstraints = {
        @UniqueConstraint(columnNames = "name")
})
@Entity
@TypeDef(name = "json", typeClass = JsonStringType.class)
@DynamicUpdate
@NoArgsConstructor
public class Identity extends HyperModel {
    /**
     * 名称
     */
    @EruptField(
            views = @View(title = "字段名"),
            edit = @Edit(title = "字段名",type = EditType.INPUT)
    )
    protected String name;
    /**
     * 中文名称
     */
    @EruptField(
            views = @View(title = "字段名"),
            edit = @Edit(title = "字段名",type = EditType.INPUT)
    )
    protected String cname;
    /**
     * icon
     */
    @EruptField(
            views = @View(title = "字段名"),
            edit = @Edit(title = "字段名",type = EditType.INPUT)
    )
    protected String icon;
    @EruptField(
            views = @View(title = "字段名"),
            edit = @Edit(title = "字段名",type = EditType.INPUT)
    )
    protected String remarks;

    @EruptField(
            views = @View(title = "字段名"),
            edit = @Edit(title = "字段名",type = EditType.BOOLEAN)
    )
    protected Boolean enable = true;

    public Identity(String name) {
        this.name = name;
        this.cname = name;
    }

    public Identity(String name, String cname) {
        this.name = name;
        this.cname = cname;
    }
}
